package com.kzd.gtgame.main.mine

import androidx.fragment.app.Fragment
import com.kzd.gtgame.R
import com.kzd.gtgame.callback.AppPagerAdapter
import com.kzd.gtgame.main.KEY_GAME_DETAILS_ID
import com.kzd.gtgame.main.KEY_GAME_DETAILS_TITLE
import com.module.lemlin.owner.OwnerAbstractActivity
import kotlinx.android.synthetic.main.activity_mine_feedback.*

class MineFeedbackActivity : OwnerAbstractActivity() {

    companion object {
        private val tabs = arrayOf("游戏反馈", "投诉反馈")
    }

    private val mGameName: String?
        get() = intent?.extras?.getString(KEY_GAME_DETAILS_TITLE,null)

    private val mGameId: String?
        get() = intent?.extras?.getString(KEY_GAME_DETAILS_ID,null)

    private val mAppPagerAdapter: AppPagerAdapter by lazy {
        object : AppPagerAdapter(supportFragmentManager, tabs) {
            override fun fragment(position: Int): Fragment = if (position == 0)
                FeedbackGameFragment.newInstance(mGameName,
                    mGameId) else FeedbackCompFragment.newInstance()
        }
    }

    override val layoutResId: Int
        get() = R.layout.activity_mine_feedback

    override fun stateBar(): StatusBar {
        return StatusBar(color = R.color.white, view = flMineFeedbackBar)
    }

    override fun initView() {
        tabMineFeedbackKind.apply {
            for (item in tabs) {
                addTab(newTab().setText(item))
            }
        }.setupWithViewPager(vpMineFeedbackBody.apply {
            adapter = mAppPagerAdapter
        })
    }
}